home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / GraphicsWorkshop / Source / Converters / gif.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-15  |  7.6 KB  |  196 lines

  1. #ifndef __GIFCONVERT__
  2. #define __GIFCONVERT__
  3.  
  4. #import <Converter.h>
  5.  
  6. #define MAXNAMELEN        50
  7. #define NEXTBYTE            (*ptr++)
  8. #define IMAGESEP            0x2C
  9. #define EXTENSION             0x21
  10. #define INTERLACEMASK    0x40
  11. #define COLORMAPMASK    0x80
  12.     
  13. #define CONVERT_ERR_NONE        0
  14. #define CONVERT_ERR_WARNING    1
  15. #define CONVERT_ERR_FATAL        2
  16.  
  17. #define ERROR_NO_ERROR            0
  18. #define ERROR_UNABLE_TO_OPEN    1
  19. #define ERROR_PERMISSION_DENIED    2
  20. #define ERROR_BAD_FORMAT        3
  21. #define ERROR_TRUNCATED_FILE    4
  22. #define ERROR_NEEDSWINDOWSERV    5
  23. #define ERROR_UNABLETOLINK        6
  24. #define ERROR_UNKNOWN            7
  25.  
  26. @interface GIF : Converter
  27. {
  28. }
  29.  
  30. /*
  31.  * Initializes the object. This need not necessarily be used, but you can use it if you'd like.
  32.  * Assumes:     Nothing
  33.  * Returns:    self
  34.  * Results:    A new object is up and running.
  35.  */
  36. - init;
  37.  
  38. /*
  39.  * Frees anything used by the object.
  40.  * Assumes:    Object is instantiated.
  41.  * Results:     It is no longer valid to message the object.
  42.  */
  43. - free;
  44.  
  45. /*
  46.  * Reads the bitmap from stream. 
  47.  * Assumes:    The object has been instantiates, stream is an valid stream opened for at least
  48.  *            reading. Sender is the id of whatever object is calling the converter. 
  49.  * Returns:    id of an NXBitmapImageRep or nil if the image was unable to be read.
  50.  */
  51. - readFromStream: (NXStream *)stream from: sender;
  52.  
  53. /*
  54.  * Write the bitmaps id to stream.
  55.  * Assumes:    Object has been instantiated. At times, it's best to have used a call to the
  56.  *             save panel first, since this can set internal variables, but it's not necessary.
  57.  *            stream should be a valid NXStream opened for at least writing. Sender should
  58.  *            be the id of the caller. id is a NXBitmapImageRep, or something that responds
  59.  *            to all the message of the NXBitmapImageRep.
  60.  * Returns:    YES if the image was sucessfully writing, otherwise it returns NO.
  61.  */
  62. - (BOOL)write: (id)image toStream: (NXStream *)stream from: sender;
  63.  
  64. /*
  65.  * Similar to readFromStream but will read multiple images from a stream when present.
  66.  * Assumes:     Object instantiated. stream valid for reading. sender is id of caller.
  67.  * Returns:    id of an NXImage or nil if unable to read the image. It should return a single
  68.  *            image in the least, even for formats that don't support multiple images.
  69.  */
  70. - readAllFromStream: (NXStream *)stream from: sender;
  71.  
  72. /*
  73.  * Reverses the process of read all.
  74.  * Assumes:     Object instantiates. id is to an NXImage or something that responds to all of
  75.  *            NXImage's methods. stream is valid for writing. This should always attempt
  76.  *            to write at least one image to disk (the first usually) even for formats that 
  77.  *            don't support multiple images.
  78.  * Returns:    YES if the image is sucessfully written to disk.
  79.  */
  80. - (BOOL)writeAll: (id)image toStream: (NXStream *)stream;
  81.  
  82. /*
  83.  * Creates and lays out a custom view that the converter can use to set customization
  84.  * parameters. 
  85.  * Assumes:     Object instantiated and the window server is running. width should be the
  86.  *            maximum width the custom view can be.
  87.  * Returns:    id of a parent view or nil if this object doesn't use one.
  88.  */
  89. - customSaveView: (int)width;
  90.  
  91. /*
  92.  * This is very similar to customSaveView, however, it is used to set parameters for
  93.  * the run time loading of images. This object does not support input custom views.
  94.  * Assumes:     Object instantiated and the window server is running. width should be the
  95.  *            maximum width the custom view can be.
  96.  * Returns:    id of a parent view or nil if this object doesn't use one.
  97.  */
  98. - customOpenView: (int)width;
  99.  
  100. /*
  101.  * Returns the name of the current format, ie, the gif converter returns the string "Graphics
  102.  * Interchange Format (GIF)".
  103.  * Assumes:     Object has been instantiated.
  104.  * Returns:    A pointer to a string. The caller should always use something like strcpy to
  105.  *            get a copy of the string, since it's life is only guaranteed for the life of the
  106.  *            object.
  107.  */
  108. - (char *)getFormatName;
  109.  
  110. /*
  111.  * This is a simple interface to setting custom values of various parameters. There are
  112.  * no standards for what a converter must take of these values, so while the converter
  113.  * will tell you whether it took the value you or not, you, as the programmer, should
  114.  * not get upset when a parameter is not taken. Likewise, should the converter receive
  115.  * a request to set a parameter it does not understand, it should always refuse it with
  116.  * grace (ie, make it idiot proof.) What parameters an indivudual converter will take
  117.  * should be documented somewhere with the converters distribution.
  118.  * Assumes:    The converter is instantiated, parameter is a NULL terminated character
  119.  *            string, and ptr is a pointer to the data type. This is determined by patameter.
  120.  * Returns:    YES if the value was set, NO if the setting failed for any reason.
  121.  */
  122.  - (BOOL)setCustomParameter: (const char *)parameter withValue: (void *)ptr;
  123.  
  124. /*
  125.  * Gets a custom parameter value. See above about support for this call, as it's similar
  126.  * to setCustomParameter. Mainly, the converter should not crash when a request for
  127.  * a non-existant parameter is made.
  128.  * Assumes:     The converter is instantiated and parameter is a NULL terminater char-
  129.  *            acter string.
  130.  * Returns:    A pointer to the parameter (type depends on return value) or nil if the
  131.  *            parameter is not understood.
  132.  */
  133.  - (void *)getCustomParameter: (const char *)parameter;
  134.  
  135.  /*
  136.   * Returns a string with copyright information, name of the author, where the author
  137.   * can be reached, etc. This should only be a couple of lines, so keep it short and 
  138.   * sweet. An example might be:
  139.   * "My Image Format Converter\nby Joe Programmer\nCopyright R'N'R Software\n ...
  140.   * ... email bugs to jprogramm@system.there.edu"
  141.   * Assumes:     Converter linked and instantiated.
  142.   * Returns:    A pointer to a null terminated string. This string must be non volatile for
  143.   *             the life of the converter. Ie, as long as the programmer keeps a converter
  144.   *            linked, the pointer should be valid.
  145.   */
  146.  - (char *)copyrightNotice;
  147.  
  148.  /*
  149.   * Returns the current error state of the converter.
  150.   * Assumes:     Converter has been instantiated.
  151.   * Returns:    0 = CONVERT_ERR_NONE         Signals no error
  152.   *            1 = CONVERT_ERR_WARNING   Signals action taken, but not one expected.
  153.   *            2 = CONVERT_ERR_FATAL          Signals no action taken.
  154.   */
  155.  - (int)errorState;
  156.  
  157.  /*
  158.   * This provides support for non standard error messages. It's preferable for programmers
  159.   * to avoid this message, but in special cases where you need to express something unique,
  160.   * it is appropiate. Just remember, that the use of this message disables multilingual
  161.   * support.
  162.   * Assumes:    Converter Instantiated
  163.   * Returns:    NULL terminated string describing the error.
  164.   */
  165.  - (char *)errorStringMessage;
  166.  
  167.  /*
  168.   * This method returns YES if the converter requires the window server. Ideally, converters
  169.   * should not depend on the window server, but sometimes this cannot be avoided. For 
  170.   * example, a programmer wouldn't be expect to write a PostScript interpreter just to read
  171.   * in eps files. Note, however, that returning YES will result in the converter not working
  172.   * with command line versions of applications.
  173.   * Assumes:    Converter Instantiated
  174.   * Returns:    YES is window server is needed, NO otherwise.
  175.   */
  176. - (BOOL)needsWindowServer;
  177.  
  178.  /*
  179.   * Returns an int describing the current error message.
  180.   * Assumes:    Converter instantiated.
  181.   * Returns:    An int describing the error type. See defines for integers returned.
  182.   */
  183.  - (int)errorMessage;
  184.  
  185. /*
  186.  * Returns a string in the form <major version>.<minor version>. This is used by 
  187.  * the calling program to see what level or protocol the object will respond to. 
  188.  * Assumes:    Converter instantiated.
  189.  * Returns:    A null terminated string in the form <major version>.<minor version>.
  190.  *            For example, 1.0.
  191.  */
  192. - (char *)protocolVersion;
  193.  
  194. @end
  195.  
  196. #endif